package com.zhang.crm.controller;

import com.github.pagehelper.PageInfo;
import com.zhang.crm.pojo.TCustomerRemark;
import com.zhang.crm.result.R;
import com.zhang.crm.service.CustomerRemarkService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class CustomerRemarkController {
    @Resource
    private CustomerRemarkService customerRemarkService;

    @PostMapping("api/submitCustomerRemark")
    public R submitCustomerRemark(@RequestBody TCustomerRemark tCustomerRemark){
        Boolean b = customerRemarkService.addCustomerRemark(tCustomerRemark);
        return b ? R.OK() : R.FAIL("添加失败");
    }

    @GetMapping("api/getCustomerRemark")
    public R getCustomerRemark(@RequestParam("customerId") Integer customerId,@RequestParam("current") Integer current){
        PageInfo<TCustomerRemark> customerRemarkList = customerRemarkService.getCustomerRemarkList(customerId,current);
        return R.OK(customerRemarkList);
    }

    @PutMapping("api/customerRemarkEdit")
    public R updateCustomerRemark(@RequestBody TCustomerRemark tCustomerRemark){
        Boolean b = customerRemarkService.updateCustomerRemark(tCustomerRemark);
        return b ? R.OK() : R.FAIL("更新失败！");
    }

    @DeleteMapping("api/logicDeleteCustomerRemark")
    public R logicDeleteCustomerRemark(@RequestParam("id") Integer customerRemarkId){
        Boolean b = customerRemarkService.logicDeleteCustomerRemark(customerRemarkId);
        return b ? R.OK() : R.FAIL("更新失败！");
    }
}
